<template>
	<div class="bgfff pad20">
		<div style="padding-bottom:20px" class="font16">能源配置</div>
		<el-checkbox v-for="(item,index) in dataList" :key="index" :label="item.id" @change="change($event,item.id)"
			v-model="item.isSelect">{{item.energyName}}{{item.unit}}
		</el-checkbox>
		<div class="mt20 textCenter">
			<el-button type="primary">保存</el-button>
		</div>
	</div>
</template>

<script>
	let that
	export default {
		name: 'energyList',
		data() {
			return {
				// swiper实例  实例上有各种方法
				dataList: []
			}
		},
		mounted() {
			that = this
			that.getEnergyList()
		},

		methods: {
			change(e, id) {
				that.ajax({
					url: '/productionEquipment/energy/updateEquipEnergy',
					data: JSON.stringify({
						energyId: id
					}),
					contentType: 'application/json',
					success: function(data) {
						that.$message.success("保存成功！")
					}
				});

			},

			getEnergyList: function() {
				var _this = this;
				that.ajax({
					url: '/productionEquipment/energy/getEnergyList',
					data: {},
					success: function(data) {
						if (data.status == 1) {
							that.dataList = data.data;
						}
					}
				});
			},
		}
	}
</script>
<style scoped>
</style>